package com.abe.jmcl.base;


import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;

import com.abe.libshare.ConstantShare;
import com.abeframe.core.CrashHandler;
import com.abeframe.core.utils.Utils;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;

public class ManagerAPP extends MultiDexApplication {

    private static ManagerAPP application;

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        //工具集合
        Utils.init(this);
        //日志捕捉
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(this);
        initShare();
    }

    public static ManagerAPP getInstance() {
        if (null == application) {
            application = new ManagerAPP();
        }
        return application;
    }

    public static Context getContext() {
        return getInstance().getApplicationContext();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    private static void initShare() {
        Config.DEBUG = true;
        //设置组件化的Log开关,参数: boolean 默认为false，如需查看LOG设置为true
        UMConfigure.setLogEnabled(true);
        //友盟
        UMConfigure.init(getContext(), ConstantShare.APP_SHARE_key, ConstantShare.APP_SHARE_channel,
                UMConfigure.DEVICE_TYPE_PHONE, ConstantShare.APP_SHARE_push_secret);
    }

    {
        Config.DEBUG = true;
        PlatformConfig.setSinaWeibo(ConstantShare.APP_SHARE_SINA_APP_key, ConstantShare.APP_SHARE_SINA_APP_secret, ConstantShare.APP_SHARE_SINA_redirect_url);
    }
}
